package com.situ.company.score.service.impl;

import java.util.List;

import com.situ.company.project.model.ProjectModel;
import com.situ.company.score.dao.IScoreDao;
import com.situ.company.score.dao.impl.ScoreDaoImpl;
import com.situ.company.score.model.ScoreModel;
import com.situ.company.score.service.IScoreService;

public class ScoreServiceImpl implements IScoreService{

	private IScoreDao dao = new ScoreDaoImpl();
	@Override
	public String insert(ScoreModel model) {
		ScoreModel m1 = new ScoreModel();
		m1.setCodeEmp(model.getCodeEmp());
		m1.setCodePro(model.getCodePro());
		ScoreModel mdb = dao.selectModel(m1);
		if(mdb!=null) {
			return "repeat";
		}
		return dao.insert(model)+"";
	}

	@Override
	public String delete(ScoreModel model) {
		return dao.deleteByCode(model)+"";
	}

	@Override
	public String update(ScoreModel model) {
		return dao.updateAll(model)+"";
	}

	@Override
	public List<ScoreModel> selectList(ScoreModel model) {
		String codeemp = model.getCodeEmp();
		model.setCodeEmp(codeemp==null?"%":"%"+codeemp+"%");
		String codepro = model.getCodePro();
		model.setCodePro(codepro==null?"%":"%"+codepro+"%");
		return dao.selectList(model);
	}

	@Override
	public ScoreModel selectModel(ScoreModel model) {
		return dao.selectModel(model);
	}

	@Override
	public Integer selectCount(ScoreModel model) {
		ScoreModel m1 = new ScoreModel();
		String code_emp = model.getCodeEmp();
		m1.setCodeEmp(code_emp==null?"%":"%"+code_emp+"%");
		String code_pro = model.getCodePro();
		m1.setCodePro(code_pro==null?"%":"%"+code_pro+"%");
		return dao.selectCount(m1);
	}

}
